<template>
  <div class="hm-login">
    <van-nav-bar title="面经注册"></van-nav-bar>
    <van-form @submit="onSubmit">
      <van-field
        v-model="username"
        name="用户名"
        label="用户名"
        placeholder="用户名"
        :rules="[{ required: true, message: '请填写用户名' }]"
      />
      <van-field
        v-model="password"
        type="password"
        name="密码"
        label="密码"
        placeholder="密码"
        :rules="[{ required: true, message: '请填写密码' }]"
      />
      <div class="hm-login-btn">
        <van-button type="primary" size="large" color="#07c160"
          >注册</van-button
        >
      </div>
    </van-form>

    <div class="gore">
      <div class="right"></div>
      <router-link to="/login" class="left">去登录</router-link>
    </div>
  </div>
</template>

<script>
import axios from "axios";
export default {
  name: "HmLogin",
  data() {
    return {
      username: "",
      password: "",
      msg: "",
    };
  },
  methods: {
    // check(v) {
    //   if (v == "") {
    //     this.msg = "请输入用户名";
    //     return false;
    //   } else if (v.length < 5) {
    //     this.msg = "用户名至少包含5个字符";
    //     return true;
    //   } else {
    //     this.msg = "";
    //     return true;
    //   }
    // },
    onSubmit() {
      // http://interview-api-t.itheima.net/h5/user/register
      // console.log("submit", values);
      axios({
        url:'http://interview-api-t.itheima.net/h5/user/register',
        method:'post',
        data:{
            username:this.username,
            password:this.password,
        }
      });
    },
  },
};
</script>

<style lang="less" scoped>
.hm-login {
  .hm-login-btn {
    padding: 10px 10px;
    margin-top: 20px;
  }
  .gore {
    display: flex;
    .right {
      flex: 1;
    }
    .left {
      min-width: 100px;
      color: #006699;
    }
  }
}
</style>
